from flask import Flask
from flask import request, jsonify
from index import db
from coupon import bp_coupon
from goods import *
from flask_cors import CORS
app = Flask(__name__)

cors = CORS(app)
# #注册蓝图
app.register_blueprint(bp_coupon,url_prefix = '/coupon')
app.register_blueprint(db_goods,url_prefix = '/goods')



# 解决中文乱码
app.config['JSON_AS_ASCII'] = False


# 视图
# @app.route('/')
# def hello_world():
#     return {"code": 200, "mes": "你好曹宝福"}
# # 查询所有
# @app.route('/find')
# def find():
#     sql = 'select * from tea'
#     res = db.findall(sql)
#     print(res)
#     return "ok"
# # 添加
# @app.route('/add', methods=['POST', 'GET'])
# def add():
#     # request.form  request.args  request.data
#     username = request.form.get('username')
#     password = request.form.get('password')
#     # 给老师表加入数据
#     sql = "insert into tea(username,password) values('%s','%s')" % (username, password)
#     db.insert(sql)
#     return 'ok'
#
# @app.route('/delete',methods=['POST','GET'])
# def delete():
#     id = request.args.get('id')
#     sql = 'delete from tea where id = %s'%(id)
#     db.insert(sql)
#     return "ok"





# 调用实例对象
if __name__ == '__main__':
    app.run(debug=True,port=5000)  # 开启调试模式
